package com.ymatou.cs.api.testcase;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.ymatou.cs.api.service.AddReturnExpressCodeCall;
import com.ymatou.cs.api.service.CreateReturnApplyBillCall;
import com.ymatou.ics.api.service.AgreeApplyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.sqlwapper.AgreeApplyWapper;
import com.ymttest.database.sqlwapper.CreateReturnApplyBillWapper;
import com.ymttest.utils.JsonBeanHelper;
/**
*CreateReturnApplyBill
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_AddReturnExpressCode
{
	private static AddReturnExpressCodeCall ddReturnExpressCodeCall;
	private static CreateReturnApplyBillCall createreturnapplybillCall;
	private static AgreeApplyCall agreeapplyCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("AddReturnExpressCodeCall");
	}

	@Before
	public void caseUp() {
		
	}

	@AfterClass
	public static void tearDown() {
		//Logger.generateResult(createreturnapplybillCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void TC_CreateReturnApplyBill_001() {
		Logger.start(true,"买家添加运单号");

		try {
			
			//获取买家ToKen
			Logger.debug("************************创建Token************************");
			ddReturnExpressCodeCall = new AddReturnExpressCodeCall("lunchzhao", "123456");
			
			
			 Logger.debug("************************买家添加运单号************************");

			 Map<String, Object> AddReturnExpressCode = new HashMap<String, Object>();		
			 	AddReturnExpressCode.put("ReturnId","TH1612130051");			    
			 	AddReturnExpressCode.put("expressBillNumber","DJJ-TEST123456");
			 	AddReturnExpressCode.put("expressCoCode","shunfeng");
			 	AddReturnExpressCode.put("expressCoName","顺丰快递");
				 
			 
				//调用接口json文件
				JSONObject AddReturnExpress =  JsonBeanHelper.getJsonBean("/com.ymatou.ics.api.agreeapply/AddReturnExpressCode/AddReturnExpressCodeTpl.json");
				AddReturnExpress = JsonBeanHelper.updateJsonBean(AddReturnExpress, AddReturnExpressCode); 		
				JSONObject result1 = ddReturnExpressCodeCall.callAndGetReturnData(AddReturnExpress);
				
				Logger.debug(result1);																			
				//断言
				String Status = result1.getString("Status");
				Logger.verifyIsContains(Status, 200, "\"Code\":200");
				
				String BCode=result1.getString("bCode");
				Logger.verifyIsContains(BCode, 0,  "\"BCode\":0");
				
				
				
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}